package com.hospital.tools;

import android.content.Context;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;

/**
 * Created by wangjun on 2015/5/26.
 */
public class MyGestureDetector extends GestureDetector.SimpleOnGestureListener {

        private Context context;
        private View view;

        public MyGestureDetector(final Context context, final View view){
            this.context = context;
            this.view = view;
        }

        /**
         * ????????????????????????Touch down??????????????
         */
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            System.out.println("*********onDoubleTap*******");
            return super.onDoubleTap(e);
        }

        /**
         * ????????????????????????Touch down??????up????????????????????????????????????e.getAction()??????????????
         */
        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            System.out.println("*********onDoubleTapEvent*******");
            return super.onDoubleTapEvent(e);
        }

        /**
         * Touch down??????????????
         */
        @Override
        public boolean onDown(MotionEvent e) {
            System.out.println("*********onDown*******");
            return super.onDown(e);
        }

        /**
         * Touch??????????????????????????????????up????????????????????
         */
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float x,
                               float y) {
            System.out.println("*********onFling*******" + x + "******" + y);
            return super.onFling(e1, e2, x, y);
        }

        /**
         * Touch????????????????????Touch down??????????????
         */
        @Override
        public void onLongPress(MotionEvent e) {
            System.out.println("*********onLongPress*******");
            super.onLongPress(e);
        }

        /**Touch??????????????????????????????????
         *?????????x,y??
         * ????????????????????y????????????????????????????x???????? e1??????????????????????Event??????e2,???????????????????????Event
         */
        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float x,
                                float y) {
            System.out.println("*********onScroll*******" + x + "*******" + y);
            return super.onScroll(e1, e2, x, y);
        }

        /**
         * Touch??????????????????????????????????????
         * onDown????Touch down??????????????????????????????????
         * ??????Touchdown???????????????????????????????????????????????onShowPress????????????onLongPress??????
         * ????????????Touchdown??????????????????????????????????onDown->onShowPress->onLongPress???????????????????????????
         */
        @Override
        public void onShowPress(MotionEvent e) {
            System.out.println("*********onShowPress*******");
            super.onShowPress(e);
        }

        /**
         * ??????onSingleTapup??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????onSingleTapUp??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
         */
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            System.out.println("*********onSingleTapConfirmed*******");
            Util.hideSoftInput(this.view, this.context);
            return super.onSingleTapConfirmed(e);
        }

        /**
         * ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
         */
        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            System.out.println("*********onSingleTapUp*******");
            return super.onSingleTapUp(e);
        }


}
